

package com.core.service;

import com.core.bean.Goods;
import com.core.bean.Product;
import com.core.dao.IGoodsDao;
import com.core.dao.jdbcmysql.JdbcMysqlFactory;
import com.core.dao.mybatismysql.MybatisMysqlFactory;

import java.util.List;
import java.util.UUID;

public class AddGoodsService {
    private List<Goods> goods;
    private Product product;
    private final int STATUS = 1;

    public void save(Goods goods) throws Exception {
        // IGoodsDao goodsDao = MybatisMysqlFactory.create(MybatisMysqlFactory.MYBATIS_MYSQL_DAO).getGoodsDao();
        // Goods good = new Goods();
        // good.setId(UUID.randomUUID().toString().replace("-", ""));
        //        good.setPrice(goods.getPrice());
        //        good.setStatus(STATUS);
        //        good.setPid(goods.getPid());
        //        good.setProperty(goods.getProperty());
        IGoodsDao goodsDao = JdbcMysqlFactory.create(JdbcMysqlFactory.JDBC_MYSQL_DAO).getGoodsDao();
        goods.setId(UUID.randomUUID().toString().replace("-", ""));
        goods.setStatus(STATUS);
        goodsDao.add(goods);
    }

    public List<Goods> createSKU(Product product) throws Exception {
        IGoodsDao goodsDao = MybatisMysqlFactory.create(MybatisMysqlFactory.MYBATIS_MYSQL_DAO).getGoodsDao();
        goods = goodsDao.findByPropertyId(product.getId());
        return goods;
    }

}
